﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BackGround : MonoBehaviour {

    public float scrollSpeed = 0.1f;

    float totalTime = 0;
    // Start is called before the first frame update
    void Start () {

    }

    // Update is called once per frame
    void Update () {
        // 根据时间让数值从0到1进行变化(自增) 到达1 的时候进行重置 重复
        // float y = Mathf.Repeat (Time.time * scrollSpeed, 1);
        float y = Mathf.Repeat (totalTime * scrollSpeed, 1);
        totalTime+= Time.deltaTime;
        
        // Debug.Log (" Mathf.Repeat:" + y);
        // Debug.Log (" Mathf.Repeat:" + totalTime);


        // 让材质贴图上的Y轴进行位移

        GetComponent<Renderer>().sharedMaterial.SetTextureOffset("_MainTex", new Vector2(0,y));
    }
}